package com.cg.controller;

import com.cg.client.ItemClient;
import com.cg.dto.*;
import com.cg.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/p")
@Slf4j
public class ItemApiController {

    @Resource
    private ItemClient itemClient;

    //1. 根据分类查询轮播图
    @PostMapping("/querySlideShowPic")
    public Dto<List<HotItems>> querySlideShowPic(HotDto hotDto){
        return itemClient.querySlideShowPic(hotDto);
    }


    //根据商品ID返回商品详情页
    @PostMapping("/queryItemDetail")
    public Dto<ItemDetailVo> queryItemDetail(@RequestBody ItemDetailDto itemDetailDto){
        return itemClient.queryItemDetail(itemDetailDto);
    }


    //根据商品id查询商品排期
    @PostMapping("/queryItemScheduler")
    public Dto<List<ItemSchedulerVo>> queryItemScheduler(@RequestBody ItemSchedulerDto itemSchedulerDto){
        return itemClient.queryItemScheduler(itemSchedulerDto);
    }



    //根据商品排期查询商品价格
    @PostMapping("/queryItemPrice")
    public Dto<List<ItemPriceVo>> queryItemPrice(@RequestBody ItemPriceDto itemPriceDto){
        return itemClient.queryItemPrice(itemPriceDto);
    }


    //根据商品id查询剧评
    @PostMapping("/queryItemComment")
    public Dto<List<ItemCommentVo>> queryItemComment(@RequestBody ItemCommentDto itemCommentDto){
        return itemClient.queryItemComment(itemCommentDto);
    }


    //推荐接口
    @PostMapping("/queryItemRecommend")
    public Dto<List<ItemRecommendVo>> queryItemRecommend(@RequestBody ItemRecommendDto itemRecommendDto){
        log.info("limit:{}"+itemRecommendDto.getLimit());
        return itemClient.queryItemRecommend(itemRecommendDto);
    }


    //猜你喜欢接口
    @PostMapping("/queryItemLike")
    public Dto<List<QueryItemLikeVo>> queryItemLike(@RequestBody Map<String,String> map){

        String itemTypeId = map.get("itemTypeId");

        return itemClient.queryItemLike(Long.parseLong(itemTypeId));
    }


    @PostMapping("/queryItemByMonth")
    public Dto<List<DayItemVo>> queryItemByMonth(@RequestBody DayItemDto dto){
        return itemClient.queryItemByMonth(dto);
    }
}
